#ifndef ROLLINGOUT_H
#define ROLLINGOUT_H

#include <algorithm>
#include "state.h"
#include "stateid.h"
#include "../manager.h"
#include "../eventmanager.h"
#include "../route.h"
#include "../properties.h"

namespace state {

const uint32_t ROLLINGOUT_TIME = 15 * 1000;
	
struct RollingOut : public State {
	RollingOut(int id) : State(id) {}
	
	virtual void onEnter() {
		Manager::Instance().getRoute()->switchToRollingLeg();
		Manager::Instance().getEventManager()->setTimer(ROLLINGOUT_TIME);		
		
		PropAccessor p;
		p().fcs.roll.set(Roll_SetPoint, 0);
		p().fcs.pitch.set(Pitch_SetPoint, 0);
		p().fcs.yaw.set(Yaw_Track);
		p().fcs.throttle.set(Throttle_Value, -1);
		p().fcs.flaps.set(Flaps_Value, Flaps_Value_Landing);
		p().fcs.brakes.set(Brakes_Value, 1);
		p().fcs.state = getId();

		p().fcs.parachute_armed = false;
	}
};


}

#endif
